package com.example.springboot01;


public class IndexUtil {

    // 2 ^
    public static int index(Object key, int size){
        int h;
        return ((h = key.hashCode()) ^ (h >>> 16)) & (size - 1);
    }


    public static void main(String[] args) {
        for (int i = 0; i < 8; i++) {
            System.out.println(i + ":" + index(i, 4));
        }
        System.out.println("===================================");

        for (int i = 0; i < 8; i++) {
            System.out.println(i + ":" + index(i, 8));
        }
    }

}
